package com.itheima.test;

import com.aliyun.teaopenapi.models.*;
import com.aliyun.dysmsapi20170525.models.*;

public class Sample {
    public static void main(String[] args) throws Exception {
        //发送短信验证码代码
        String  accessKeyId ="LTAI5tAshvkpTFLP5BzGtMaX";
        String  accessKeySecret = "N4zWE4kjnxBQy1iujS2ElqR1JCbYwB";


        Config config = new Config()
                // 您的AccessKey ID
                .setAccessKeyId(accessKeyId)
                // 您的AccessKey Secret
                .setAccessKeySecret(accessKeySecret)
                .setEndpoint("dysmsapi.aliyuncs.com");

        com.aliyun.dysmsapi20170525.Client client = new  com.aliyun.dysmsapi20170525.Client(config);

        SendSmsRequest sendSmsRequest = new SendSmsRequest()
                .setPhoneNumbers( "19577731050") //目标手机号
                .setSignName("探花平台") //签名名称
                .setTemplateCode("SMS_204055119") //短信模板code
                .setTemplateParam("{\"code\":\"1234\"}"); //模板中变量替换
        SendSmsResponse sendSmsResponse = client.sendSms(sendSmsRequest);
        SendSmsResponseBody body = sendSmsResponse.getBody();
        // code = OK 代表成功
        System.out.println(body.getCode() + "  " + body.getMessage());


    }
}
